#include	"Client.h" 

Client::Client(){
}

Client::~Client(){
}

void Client::initCommunication(string hostname, int portCom, int portBroadcast, int tailleTampon){
	//Initialisation du client TCP
	this->communicateur = new ClientTCP(hostname, portCom, tailleTampon,this);
	//Initialisation du client UDP
	this->broadcast = new ClientUDP(hostname, portBroadcast, tailleTampon);//TODO passer le listenner   ----
	
	this->communicateur->connexion();
	this->communicateur->protocoleDeCommunication();
}

void Client::afficherMessage(string message){
	cout<<message<<endl;
}

string Client::saisirReponse(){
	string reponse;
	getline(cin,reponse);
	//cin>>reponse;
	return reponse;
}

int Client::action(int numAction, string message, int descripteur){
	this->afficherMessage(message);
	if(message == "%quit"){
		this->communicateur->deconnexion();
	}
	string reponse = this->saisirReponse();
	this->communicateur->envoyer(reponse);
	return numAction;
}

string Client::getAction(int numAction, int descripteur){
	return "";
}

